﻿function forget(){
	if($("#cLogin").val() == "") {
		alert("请输入用户名");
		$("#cLogin").focus();
		return;
	}
	
	if($("#cEmail").val() == "") {
		alert("请输入电子邮件");
		$("#cEmail").focus();
		return;
	}
	
	if(checkEmail($("#cEmail").val()) != "true") {
		alert("Email地址不合法");
		$("#cEmail").focus();
		return;
	}
	if(!confirm("确定要找回密码吗？"))
	var gcForget = new AjaxProxy();
	gcForget.addParm("cLogin",$("#cLogin").val());
	gcForget.addParm("cEmail",$("#cEmail").val());
	gcForget.invoke("help.forgetMyPass",false);
	var flag = gcForget.getString("PN_RET");
	if(flag != 0) {
		alert(gcForget.getString("PC_MSG"));
	}else{
		alert("新密码已成功发送到你的邮件中!");
		window.location.href = "login.html";
	}
}

function checkEmail(email){
    var errorEmailStr = "";

    var emailReg = /([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/;
    if(!emailReg.test(email)){
        errorEmailStr = "Email地址不合法！\n";
    }else{
		errorEmailStr = "true";
	}

    return errorEmailStr;
}